#coding = utf-8
import os

cwd = os.getcwd()
files = os.listdir(cwd)
k = 0
for file_name in files:
    if file_name.endswith(".jpg"):
        s = "%.5d" % k
        new_name = s + ".jpg"
        os.rename(file_name, new_name)
        k = k + 1